Dragonfly2

Форк
0
59 строк · 1.6 Кб
1
/*
2
 *     Copyright 2022 The Dragonfly Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package service
18

19
import (
20
	"context"
21
	"errors"
22

23
	"d7y.io/dragonfly/v2/manager/types"
24
	"d7y.io/dragonfly/v2/pkg/objectstorage"
25
)
26

27
var ErrObjectStorageDisabled = errors.New("object storage is disabled")
28

29
func (s *service) CreateBucket(ctx context.Context, json types.CreateBucketRequest) error {
30
	if s.objectStorage == nil {
31
		return ErrObjectStorageDisabled
32
	}
33

34
	return s.objectStorage.CreateBucket(ctx, json.Name)
35
}
36

37
func (s *service) DestroyBucket(ctx context.Context, id string) error {
38
	if s.objectStorage == nil {
39
		return ErrObjectStorageDisabled
40
	}
41

42
	return s.objectStorage.DeleteBucket(ctx, id)
43
}
44

45
func (s *service) GetBucket(ctx context.Context, id string) (*objectstorage.BucketMetadata, error) {
46
	if s.objectStorage == nil {
47
		return nil, ErrObjectStorageDisabled
48
	}
49

50
	return s.objectStorage.GetBucketMetadata(ctx, id)
51
}
52

53
func (s *service) GetBuckets(ctx context.Context) ([]*objectstorage.BucketMetadata, error) {
54
	if s.objectStorage == nil {
55
		return nil, ErrObjectStorageDisabled
56
	}
57

58
	return s.objectStorage.ListBucketMetadatas(ctx)
59
}
60

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.