1
|
|
|
package s3 |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"time" |
5
|
|
|
|
6
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/s3" |
7
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
8
|
|
|
) |
9
|
|
|
|
10
|
|
|
type AccessControlPolicy struct { |
|
|
|
|
11
|
|
|
Grants []Grant |
12
|
|
|
Owner Owner |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
func (r AccessControlPolicy) ToSDK() *SDK.AccessControlPolicy { |
|
|
|
|
16
|
|
|
if len(r.Grants) == 0 { |
17
|
|
|
return nil |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
o := &SDK.AccessControlPolicy{} |
21
|
|
|
|
22
|
|
|
if len(r.Grants) != 0 { |
23
|
|
|
list := make([]SDK.Grant, len(r.Grants)) |
24
|
|
|
for i, v := range r.Grants { |
25
|
|
|
list[i] = v.ToSDK() |
26
|
|
|
} |
27
|
|
|
o.Grants = list |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
v := r.Owner.ToSDK() |
31
|
|
|
o.Owner = &v |
32
|
|
|
return o |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
type Bucket struct { |
|
|
|
|
36
|
|
|
CreationDate time.Time |
37
|
|
|
Name string |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
func newBuckets(list []SDK.Bucket) []Bucket { |
41
|
|
|
if len(list) == 0 { |
42
|
|
|
return nil |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
results := make([]Bucket, len(list)) |
46
|
|
|
for i, v := range list { |
47
|
|
|
results[i] = newBucket(v) |
48
|
|
|
} |
49
|
|
|
return results |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
func newBucket(b SDK.Bucket) Bucket { |
53
|
|
|
result := Bucket{} |
54
|
|
|
|
55
|
|
|
if b.CreationDate != nil { |
56
|
|
|
result.CreationDate = *b.CreationDate |
57
|
|
|
} |
58
|
|
|
if b.Name != nil { |
59
|
|
|
result.Name = *b.Name |
60
|
|
|
} |
61
|
|
|
return result |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
type Delete struct { |
|
|
|
|
65
|
|
|
Objects []ObjectIdentifier |
66
|
|
|
Quiet bool |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
func (r Delete) ToSDK() SDK.Delete { |
|
|
|
|
70
|
|
|
o := SDK.Delete{} |
71
|
|
|
|
72
|
|
|
if len(r.Objects) != 0 { |
73
|
|
|
list := make([]SDK.ObjectIdentifier, len(r.Objects)) |
74
|
|
|
for i, v := range r.Objects { |
75
|
|
|
list[i] = v.ToSDK() |
76
|
|
|
} |
77
|
|
|
o.Objects = list |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if r.Quiet { |
81
|
|
|
o.Quiet = pointers.Bool(r.Quiet) |
82
|
|
|
} |
83
|
|
|
return o |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
type DeletedObject struct { |
|
|
|
|
87
|
|
|
DeleteMarker bool |
88
|
|
|
DeleteMarkerVersionID string |
89
|
|
|
Key string |
90
|
|
|
VersionID string |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
func newDeletedObjects(list []SDK.DeletedObject) []DeletedObject { |
94
|
|
|
if len(list) == 0 { |
95
|
|
|
return nil |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
result := make([]DeletedObject, len(list)) |
99
|
|
|
for i, v := range list { |
100
|
|
|
result[i] = newDeletedObject(v) |
101
|
|
|
} |
102
|
|
|
return result |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
func newDeletedObject(o SDK.DeletedObject) DeletedObject { |
106
|
|
|
result := DeletedObject{} |
107
|
|
|
|
108
|
|
|
if o.DeleteMarker != nil { |
109
|
|
|
result.DeleteMarker = *o.DeleteMarker |
110
|
|
|
} |
111
|
|
|
if o.DeleteMarkerVersionId != nil { |
112
|
|
|
result.DeleteMarkerVersionID = *o.DeleteMarkerVersionId |
113
|
|
|
} |
114
|
|
|
if o.Key != nil { |
115
|
|
|
result.Key = *o.Key |
116
|
|
|
} |
117
|
|
|
if o.VersionId != nil { |
118
|
|
|
result.VersionID = *o.VersionId |
119
|
|
|
} |
120
|
|
|
return result |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
type DeleteMarkerEntry struct { |
|
|
|
|
124
|
|
|
IsLatest bool |
125
|
|
|
Key string |
126
|
|
|
LastModified time.Time |
127
|
|
|
Owner Owner |
128
|
|
|
VersionID string |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
func newDeleteMarkerEntries(list []SDK.DeleteMarkerEntry) []DeleteMarkerEntry { |
132
|
|
|
if len(list) == 0 { |
133
|
|
|
return nil |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
result := make([]DeleteMarkerEntry, len(list)) |
137
|
|
|
for i, v := range list { |
138
|
|
|
result[i] = newDeleteMarkerEntry(v) |
139
|
|
|
} |
140
|
|
|
return result |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
func newDeleteMarkerEntry(o SDK.DeleteMarkerEntry) DeleteMarkerEntry { |
144
|
|
|
result := DeleteMarkerEntry{} |
145
|
|
|
|
146
|
|
|
if o.IsLatest != nil { |
147
|
|
|
result.IsLatest = *o.IsLatest |
148
|
|
|
} |
149
|
|
|
if o.Key != nil { |
150
|
|
|
result.Key = *o.Key |
151
|
|
|
} |
152
|
|
|
if o.LastModified != nil { |
153
|
|
|
result.LastModified = *o.LastModified |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
result.Owner = newOwner(o.Owner) |
157
|
|
|
|
158
|
|
|
if o.VersionId != nil { |
159
|
|
|
result.VersionID = *o.VersionId |
160
|
|
|
} |
161
|
|
|
return result |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
type Error struct { |
|
|
|
|
165
|
|
|
Code string |
166
|
|
|
Key string |
167
|
|
|
Message string |
168
|
|
|
VersionID string |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
func newErrors(list []SDK.Error) []Error { |
172
|
|
|
if len(list) == 0 { |
173
|
|
|
return nil |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
result := make([]Error, len(list)) |
177
|
|
|
for i, v := range list { |
178
|
|
|
result[i] = newError(v) |
179
|
|
|
} |
180
|
|
|
return result |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
func newError(o SDK.Error) Error { |
184
|
|
|
result := Error{} |
185
|
|
|
|
186
|
|
|
if o.Code != nil { |
187
|
|
|
result.Code = *o.Code |
188
|
|
|
} |
189
|
|
|
if o.Key != nil { |
190
|
|
|
result.Key = *o.Key |
191
|
|
|
} |
192
|
|
|
if o.Message != nil { |
193
|
|
|
result.Message = *o.Message |
194
|
|
|
} |
195
|
|
|
if o.VersionId != nil { |
196
|
|
|
result.VersionID = *o.VersionId |
197
|
|
|
} |
198
|
|
|
return result |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
type Grant struct { |
|
|
|
|
202
|
|
|
GranteeDisplayName string |
203
|
|
|
GranteeEmailAddress string |
204
|
|
|
GranteeID string |
205
|
|
|
GranteeType Type |
206
|
|
|
GranteeURI string |
207
|
|
|
Permission Permission |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
func newGrants(list []SDK.Grant) []Grant { |
211
|
|
|
if len(list) == 0 { |
212
|
|
|
return nil |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
result := make([]Grant, len(list)) |
216
|
|
|
for i, v := range list { |
217
|
|
|
result[i] = newGrant(v) |
218
|
|
|
} |
219
|
|
|
return result |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
func newGrant(o SDK.Grant) Grant { |
223
|
|
|
result := Grant{} |
224
|
|
|
|
225
|
|
|
g := o.Grantee |
226
|
|
|
if g.DisplayName != nil { |
227
|
|
|
result.GranteeDisplayName = *g.DisplayName |
228
|
|
|
} |
229
|
|
|
if g.EmailAddress != nil { |
230
|
|
|
result.GranteeEmailAddress = *g.EmailAddress |
231
|
|
|
} |
232
|
|
|
if g.ID != nil { |
233
|
|
|
result.GranteeID = *g.ID |
234
|
|
|
} |
235
|
|
|
if g.Type != "" { |
236
|
|
|
result.GranteeType = Type(g.Type) |
237
|
|
|
} |
238
|
|
|
if g.URI != nil { |
239
|
|
|
result.GranteeURI = *g.URI |
240
|
|
|
} |
241
|
|
|
if o.Permission != "" { |
242
|
|
|
result.Permission = Permission(o.Permission) |
243
|
|
|
} |
244
|
|
|
return result |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
func (r Grant) ToSDK() SDK.Grant { |
|
|
|
|
248
|
|
|
o := SDK.Grant{} |
249
|
|
|
|
250
|
|
|
g := SDK.Grantee{} |
251
|
|
|
if r.GranteeDisplayName != "" { |
252
|
|
|
g.DisplayName = pointers.String(r.GranteeDisplayName) |
253
|
|
|
} |
254
|
|
|
if r.GranteeEmailAddress != "" { |
255
|
|
|
g.EmailAddress = pointers.String(r.GranteeEmailAddress) |
256
|
|
|
} |
257
|
|
|
if r.GranteeID != "" { |
258
|
|
|
g.ID = pointers.String(r.GranteeID) |
259
|
|
|
} |
260
|
|
|
if r.GranteeURI != "" { |
261
|
|
|
g.URI = pointers.String(r.GranteeURI) |
262
|
|
|
} |
263
|
|
|
g.Type = SDK.Type(r.GranteeType) |
264
|
|
|
|
265
|
|
|
o.Permission = SDK.Permission(r.Permission) |
266
|
|
|
return o |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
type LifecycleRule struct { |
|
|
|
|
270
|
|
|
Expiration LifecycleExpiration |
271
|
|
|
Filter LifecycleRuleFilter |
272
|
|
|
ID string |
273
|
|
|
NoncurrentVersionTransitions []NoncurrentVersionTransition |
274
|
|
|
Prefix string |
275
|
|
|
Status ExpirationStatus |
276
|
|
|
Transitions []Transition |
277
|
|
|
|
278
|
|
|
AbortIncompleteMultipartUploadDaysAfterInitiation int64 |
279
|
|
|
NoncurrentVersionExpirationDays int64 |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
func newLifecycleRules(list []SDK.LifecycleRule) []LifecycleRule { |
283
|
|
|
if len(list) == 0 { |
284
|
|
|
return nil |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
results := make([]LifecycleRule, len(list)) |
288
|
|
|
for i, v := range list { |
289
|
|
|
results[i] = newLifecycleRule(v) |
290
|
|
|
} |
291
|
|
|
return results |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
func newLifecycleRule(o SDK.LifecycleRule) LifecycleRule { |
295
|
|
|
result := LifecycleRule{} |
296
|
|
|
|
297
|
|
|
result.Expiration = newLifecycleExpiration(o.Expiration) |
298
|
|
|
|
299
|
|
|
if o.Filter != nil { |
300
|
|
|
result.Filter = newLifecycleRuleFilter(o.Filter) |
301
|
|
|
} |
302
|
|
|
if o.ID != nil { |
303
|
|
|
result.ID = *o.ID |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
result.NoncurrentVersionTransitions = newNoncurrentVersionTransitions(o.NoncurrentVersionTransitions) |
307
|
|
|
|
308
|
|
|
if o.Prefix != nil { |
309
|
|
|
result.Prefix = *o.Prefix |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
result.Status = ExpirationStatus(o.Status) |
313
|
|
|
result.Transitions = newTransitions(o.Transitions) |
314
|
|
|
|
315
|
|
|
if v := o.AbortIncompleteMultipartUpload; v != nil { |
316
|
|
|
if v.DaysAfterInitiation != nil { |
317
|
|
|
result.AbortIncompleteMultipartUploadDaysAfterInitiation = *v.DaysAfterInitiation |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
if v := o.NoncurrentVersionExpiration; v != nil { |
321
|
|
|
if v.NoncurrentDays != nil { |
322
|
|
|
result.NoncurrentVersionExpirationDays = *v.NoncurrentDays |
323
|
|
|
} |
324
|
|
|
} |
325
|
|
|
return result |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
func (r LifecycleRule) ToSDK() SDK.LifecycleRule { |
|
|
|
|
329
|
|
|
o := SDK.LifecycleRule{} |
330
|
|
|
|
331
|
|
|
if r.ID != "" { |
332
|
|
|
o.ID = pointers.String(r.ID) |
333
|
|
|
} |
334
|
|
|
if r.Prefix != "" { |
335
|
|
|
o.Prefix = pointers.String(r.Prefix) |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
o.Status = SDK.ExpirationStatus(r.Status) |
339
|
|
|
|
340
|
|
|
if r.AbortIncompleteMultipartUploadDaysAfterInitiation != 0 { |
341
|
|
|
o.AbortIncompleteMultipartUpload = &SDK.AbortIncompleteMultipartUpload{ |
342
|
|
|
DaysAfterInitiation: pointers.Long64(r.AbortIncompleteMultipartUploadDaysAfterInitiation), |
343
|
|
|
} |
344
|
|
|
} |
345
|
|
|
if r.NoncurrentVersionExpirationDays != 0 { |
346
|
|
|
o.NoncurrentVersionExpiration = &SDK.NoncurrentVersionExpiration{ |
347
|
|
|
NoncurrentDays: pointers.Long64(r.NoncurrentVersionExpirationDays), |
348
|
|
|
} |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
if len(r.NoncurrentVersionTransitions) != 0 { |
352
|
|
|
list := make([]SDK.NoncurrentVersionTransition, len(r.NoncurrentVersionTransitions)) |
353
|
|
|
for i, v := range r.NoncurrentVersionTransitions { |
354
|
|
|
list[i] = v.ToSDK() |
355
|
|
|
} |
356
|
|
|
o.NoncurrentVersionTransitions = list |
357
|
|
|
} |
358
|
|
|
if len(r.Transitions) != 0 { |
359
|
|
|
list := make([]SDK.Transition, len(r.Transitions)) |
360
|
|
|
for i, v := range r.Transitions { |
361
|
|
|
list[i] = v.ToSDK() |
362
|
|
|
} |
363
|
|
|
o.Transitions = list |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
if !r.Expiration.IsEmpty() { |
367
|
|
|
v := r.Expiration.ToSDK() |
368
|
|
|
o.Expiration = &v |
369
|
|
|
} |
370
|
|
|
if !r.Filter.IsEmpty() { |
371
|
|
|
v := r.Filter.ToSDK() |
372
|
|
|
o.Filter = &v |
373
|
|
|
} |
374
|
|
|
return o |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
type LifecycleRuleFilter struct { |
|
|
|
|
378
|
|
|
AndOperatorPrefix string |
379
|
|
|
AndOperatorTags []Tag |
380
|
|
|
Prefix string |
381
|
|
|
Tag Tag |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
func newLifecycleRuleFilter(o *SDK.LifecycleRuleFilter) LifecycleRuleFilter { |
385
|
|
|
result := LifecycleRuleFilter{} |
386
|
|
|
if o == nil { |
387
|
|
|
return result |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
if o.And != nil { |
391
|
|
|
a := o.And |
392
|
|
|
if a.Prefix != nil { |
393
|
|
|
result.AndOperatorPrefix = *a.Prefix |
394
|
|
|
} |
395
|
|
|
if len(a.Tags) != 0 { |
396
|
|
|
result.AndOperatorTags = newTags(a.Tags) |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
if o.Prefix != nil { |
400
|
|
|
result.Prefix = *o.Prefix |
401
|
|
|
} |
402
|
|
|
if o.Tag != nil { |
403
|
|
|
result.Tag = newTag(*o.Tag) |
404
|
|
|
} |
405
|
|
|
return result |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
func (r LifecycleRuleFilter) IsEmpty() bool { |
|
|
|
|
409
|
|
|
switch { |
410
|
|
|
case r.Prefix != "", |
411
|
|
|
r.AndOperatorPrefix != "", |
412
|
|
|
len(r.AndOperatorTags) != 0, |
413
|
|
|
!r.Tag.IsEmpty(): |
414
|
|
|
return false |
415
|
|
|
} |
416
|
|
|
return true |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
func (r LifecycleRuleFilter) ToSDK() SDK.LifecycleRuleFilter { |
|
|
|
|
420
|
|
|
o := SDK.LifecycleRuleFilter{} |
421
|
|
|
if r.Prefix != "" { |
422
|
|
|
o.Prefix = pointers.String(r.Prefix) |
423
|
|
|
} |
424
|
|
|
if !r.Tag.IsEmpty() { |
425
|
|
|
v := r.Tag.ToSDK() |
426
|
|
|
o.Tag = &v |
427
|
|
|
} |
428
|
|
|
if r.AndOperatorPrefix != "" || len(r.AndOperatorTags) != 0 { |
429
|
|
|
and := &SDK.LifecycleRuleAndOperator{} |
430
|
|
|
if r.AndOperatorPrefix != "" { |
431
|
|
|
and.Prefix = pointers.String(r.AndOperatorPrefix) |
432
|
|
|
} |
433
|
|
|
if len(r.AndOperatorTags) != 0 { |
434
|
|
|
list := make([]SDK.Tag, len(r.AndOperatorTags)) |
435
|
|
|
for i, v := range r.AndOperatorTags { |
436
|
|
|
list[i] = v.ToSDK() |
437
|
|
|
} |
438
|
|
|
and.Tags = list |
439
|
|
|
} |
440
|
|
|
} |
441
|
|
|
return o |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
type LifecycleExpiration struct { |
|
|
|
|
445
|
|
|
Date time.Time |
446
|
|
|
Days int64 |
447
|
|
|
ExpiredObjectDeleteMarker bool |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
func newLifecycleExpiration(o *SDK.LifecycleExpiration) LifecycleExpiration { |
451
|
|
|
result := LifecycleExpiration{} |
452
|
|
|
if o == nil { |
453
|
|
|
return result |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
if o.Date != nil { |
457
|
|
|
result.Date = *o.Date |
458
|
|
|
} |
459
|
|
|
if o.Days != nil { |
460
|
|
|
result.Days = *o.Days |
461
|
|
|
} |
462
|
|
|
if o.ExpiredObjectDeleteMarker != nil { |
463
|
|
|
result.ExpiredObjectDeleteMarker = *o.ExpiredObjectDeleteMarker |
464
|
|
|
} |
465
|
|
|
return result |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
func (r LifecycleExpiration) IsEmpty() bool { |
|
|
|
|
469
|
|
|
switch { |
470
|
|
|
case r.Days != 0, |
471
|
|
|
r.ExpiredObjectDeleteMarker, |
472
|
|
|
!r.Date.IsZero(): |
473
|
|
|
return false |
474
|
|
|
} |
475
|
|
|
return true |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
func (r LifecycleExpiration) ToSDK() SDK.LifecycleExpiration { |
|
|
|
|
479
|
|
|
o := SDK.LifecycleExpiration{} |
480
|
|
|
if r.Days != 0 { |
481
|
|
|
o.Days = pointers.Long64(r.Days) |
482
|
|
|
} |
483
|
|
|
if !r.Date.IsZero() { |
484
|
|
|
o.Date = &r.Date |
485
|
|
|
} |
486
|
|
|
if r.ExpiredObjectDeleteMarker { |
487
|
|
|
o.ExpiredObjectDeleteMarker = pointers.Bool(r.ExpiredObjectDeleteMarker) |
488
|
|
|
} |
489
|
|
|
return o |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
type NoncurrentVersionTransition struct { |
|
|
|
|
493
|
|
|
NoncurrentDays int64 |
494
|
|
|
StorageClass TransitionStorageClass |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
func newNoncurrentVersionTransitions(list []SDK.NoncurrentVersionTransition) []NoncurrentVersionTransition { |
498
|
|
|
if len(list) == 0 { |
499
|
|
|
return nil |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
results := make([]NoncurrentVersionTransition, len(list)) |
503
|
|
|
for i, v := range list { |
504
|
|
|
results[i] = newNoncurrentVersionTransition(v) |
505
|
|
|
} |
506
|
|
|
return results |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
func newNoncurrentVersionTransition(o SDK.NoncurrentVersionTransition) NoncurrentVersionTransition { |
510
|
|
|
result := NoncurrentVersionTransition{} |
511
|
|
|
|
512
|
|
|
if o.NoncurrentDays != nil { |
513
|
|
|
result.NoncurrentDays = *o.NoncurrentDays |
514
|
|
|
} |
515
|
|
|
result.StorageClass = TransitionStorageClass(o.StorageClass) |
516
|
|
|
return result |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
func (r NoncurrentVersionTransition) ToSDK() SDK.NoncurrentVersionTransition { |
|
|
|
|
520
|
|
|
o := SDK.NoncurrentVersionTransition{} |
521
|
|
|
if r.NoncurrentDays != 0 { |
522
|
|
|
o.NoncurrentDays = pointers.Long64(r.NoncurrentDays) |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
o.StorageClass = SDK.TransitionStorageClass(r.StorageClass) |
526
|
|
|
return o |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
type Object struct { |
|
|
|
|
530
|
|
|
ETag string |
531
|
|
|
Key string |
532
|
|
|
LastModified time.Time |
533
|
|
|
Size int64 |
534
|
|
|
StorageClass ObjectStorageClass |
535
|
|
|
OwnerID string |
536
|
|
|
OwnerDisplayName string |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
func NewObject(o SDK.Object) Object { |
|
|
|
|
540
|
|
|
result := Object{} |
541
|
|
|
|
542
|
|
|
if o.ETag != nil { |
543
|
|
|
result.ETag = *o.ETag |
544
|
|
|
} |
545
|
|
|
if o.Key != nil { |
546
|
|
|
result.Key = *o.Key |
547
|
|
|
} |
548
|
|
|
if o.LastModified != nil { |
549
|
|
|
result.LastModified = *o.LastModified |
550
|
|
|
} |
551
|
|
|
if o.Size != nil { |
552
|
|
|
result.Size = *o.Size |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
result.StorageClass = ObjectStorageClass(o.StorageClass) |
556
|
|
|
|
557
|
|
|
if o.Owner != nil { |
558
|
|
|
owner := o.Owner |
559
|
|
|
if owner.ID != nil { |
560
|
|
|
result.OwnerID = *owner.ID |
561
|
|
|
} |
562
|
|
|
if owner.DisplayName != nil { |
563
|
|
|
result.OwnerDisplayName = *owner.DisplayName |
564
|
|
|
} |
565
|
|
|
} |
566
|
|
|
return result |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
type ObjectIdentifier struct { |
|
|
|
|
570
|
|
|
Key string |
571
|
|
|
VersionID string |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
func (r ObjectIdentifier) ToSDK() SDK.ObjectIdentifier { |
|
|
|
|
575
|
|
|
o := SDK.ObjectIdentifier{} |
576
|
|
|
|
577
|
|
|
if r.Key != "" { |
578
|
|
|
o.Key = pointers.String(r.Key) |
579
|
|
|
} |
580
|
|
|
if r.VersionID != "" { |
581
|
|
|
o.VersionId = pointers.String(r.VersionID) |
582
|
|
|
} |
583
|
|
|
return o |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
type ObjectVersion struct { |
|
|
|
|
587
|
|
|
ETag string |
588
|
|
|
IsLatest bool |
589
|
|
|
Key string |
590
|
|
|
LastModified time.Time |
591
|
|
|
Owner Owner |
592
|
|
|
Size int64 |
593
|
|
|
StorageClass ObjectVersionStorageClass |
594
|
|
|
VersionID string |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
func newObjectVersions(list []SDK.ObjectVersion) []ObjectVersion { |
598
|
|
|
if len(list) == 0 { |
599
|
|
|
return nil |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
result := make([]ObjectVersion, len(list)) |
603
|
|
|
for i, v := range list { |
604
|
|
|
result[i] = newObjectVersion(v) |
605
|
|
|
} |
606
|
|
|
return result |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
func newObjectVersion(o SDK.ObjectVersion) ObjectVersion { |
610
|
|
|
result := ObjectVersion{} |
611
|
|
|
|
612
|
|
|
if o.ETag != nil { |
613
|
|
|
result.ETag = *o.ETag |
614
|
|
|
} |
615
|
|
|
if o.IsLatest != nil { |
616
|
|
|
result.IsLatest = *o.IsLatest |
617
|
|
|
} |
618
|
|
|
if o.Key != nil { |
619
|
|
|
result.Key = *o.Key |
620
|
|
|
} |
621
|
|
|
if o.LastModified != nil { |
622
|
|
|
result.LastModified = *o.LastModified |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
result.Owner = newOwner(o.Owner) |
626
|
|
|
|
627
|
|
|
if o.Size != nil { |
628
|
|
|
result.Size = *o.Size |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
result.StorageClass = ObjectVersionStorageClass(o.StorageClass) |
632
|
|
|
|
633
|
|
|
if o.VersionId != nil { |
634
|
|
|
result.VersionID = *o.VersionId |
635
|
|
|
} |
636
|
|
|
return result |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
type Owner struct { |
|
|
|
|
640
|
|
|
DisplayName string |
641
|
|
|
ID string |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
func newOwner(o *SDK.Owner) Owner { |
645
|
|
|
result := Owner{} |
646
|
|
|
if o == nil { |
647
|
|
|
return result |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
if o.DisplayName != nil { |
651
|
|
|
result.DisplayName = *o.DisplayName |
652
|
|
|
} |
653
|
|
|
if o.ID != nil { |
654
|
|
|
result.ID = *o.ID |
655
|
|
|
} |
656
|
|
|
return result |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
func (r Owner) ToSDK() SDK.Owner { |
|
|
|
|
660
|
|
|
o := SDK.Owner{} |
661
|
|
|
|
662
|
|
|
if r.DisplayName != "" { |
663
|
|
|
o.DisplayName = pointers.String(r.DisplayName) |
664
|
|
|
} |
665
|
|
|
if r.ID != "" { |
666
|
|
|
o.ID = pointers.String(r.ID) |
667
|
|
|
} |
668
|
|
|
return o |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
type Tag struct { |
|
|
|
|
672
|
|
|
Key string |
673
|
|
|
Value string |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
func newTags(list []SDK.Tag) []Tag { |
677
|
|
|
if len(list) == 0 { |
678
|
|
|
return nil |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
results := make([]Tag, len(list)) |
682
|
|
|
for i, v := range list { |
683
|
|
|
results[i] = newTag(v) |
684
|
|
|
} |
685
|
|
|
return results |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
func newTag(o SDK.Tag) Tag { |
689
|
|
|
result := Tag{} |
690
|
|
|
|
691
|
|
|
if o.Key != nil { |
692
|
|
|
result.Key = *o.Key |
693
|
|
|
} |
694
|
|
|
if o.Value != nil { |
695
|
|
|
result.Value = *o.Value |
696
|
|
|
} |
697
|
|
|
return result |
698
|
|
|
} |
699
|
|
|
|
700
|
|
|
func (r Tag) IsEmpty() bool { |
|
|
|
|
701
|
|
|
return r.Key == "" |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
func (r Tag) ToSDK() SDK.Tag { |
|
|
|
|
705
|
|
|
o := SDK.Tag{} |
706
|
|
|
|
707
|
|
|
if r.Key != "" { |
708
|
|
|
o.Key = pointers.String(r.Key) |
709
|
|
|
} |
710
|
|
|
if r.Value != "" { |
711
|
|
|
o.Value = pointers.String(r.Value) |
712
|
|
|
} |
713
|
|
|
return o |
714
|
|
|
} |
715
|
|
|
|
716
|
|
|
type Transition struct { |
|
|
|
|
717
|
|
|
Date time.Time |
718
|
|
|
Days int64 |
719
|
|
|
StorageClass TransitionStorageClass |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
func newTransitions(list []SDK.Transition) []Transition { |
723
|
|
|
if len(list) == 0 { |
724
|
|
|
return nil |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
results := make([]Transition, len(list)) |
728
|
|
|
for i, v := range list { |
729
|
|
|
results[i] = newTransition(v) |
730
|
|
|
} |
731
|
|
|
return results |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
func newTransition(o SDK.Transition) Transition { |
735
|
|
|
result := Transition{} |
736
|
|
|
|
737
|
|
|
if o.Date != nil { |
738
|
|
|
result.Date = *o.Date |
739
|
|
|
} |
740
|
|
|
if o.Days != nil { |
741
|
|
|
result.Days = *o.Days |
742
|
|
|
} |
743
|
|
|
result.StorageClass = TransitionStorageClass(o.StorageClass) |
744
|
|
|
return result |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
func (r Transition) ToSDK() SDK.Transition { |
|
|
|
|
748
|
|
|
o := SDK.Transition{} |
749
|
|
|
if !r.Date.IsZero() { |
750
|
|
|
o.Date = &r.Date |
751
|
|
|
} |
752
|
|
|
if r.Days != 0 { |
753
|
|
|
o.Days = pointers.Long64(r.Days) |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
o.StorageClass = SDK.TransitionStorageClass(r.StorageClass) |
757
|
|
|
return o |
758
|
|
|
} |
759
|
|
|
|