-
Notifications
You must be signed in to change notification settings - Fork 5
/
adapter.go
43 lines (34 loc) · 970 Bytes
/
adapter.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
// Copyright (c) 2021 Yandex LLC. All rights reserved.
// Author: Martynov Pavel <covariance@yandex-team.ru>
package adapter
import (
"context"
"github.com/aws/aws-sdk-go/service/s3"
)
type YandexObjectStorageAdapterSDK struct{}
func NewYandexObjectStorageAdapterSDK() (YandexObjectStorageAdapter, error) {
return &YandexObjectStorageAdapterSDK{}, nil
}
func (r *YandexObjectStorageAdapterSDK) Create(_ context.Context, sdk *s3.S3, name string) error {
_, err := sdk.CreateBucket(
&s3.CreateBucketInput{
Bucket: &name,
},
)
return err
}
func (r *YandexObjectStorageAdapterSDK) List(_ context.Context, sdk *s3.S3) ([]*s3.Bucket, error) {
res, err := sdk.ListBuckets(&s3.ListBucketsInput{})
if err != nil {
return nil, err
}
return res.Buckets, nil
}
func (r *YandexObjectStorageAdapterSDK) Delete(_ context.Context, sdk *s3.S3, name string) error {
_, err := sdk.DeleteBucket(
&s3.DeleteBucketInput{
Bucket: &name,
},
)
return err
}