2019-07-08 23:32:18 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package metainfo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/macaroon"
|
|
|
|
"storj.io/common/storj"
|
2020-03-30 10:08:50 +01:00
|
|
|
"storj.io/common/uuid"
|
2020-07-24 18:13:15 +01:00
|
|
|
"storj.io/storj/satellite/metainfo/metabase"
|
2019-07-08 23:32:18 +01:00
|
|
|
)
|
|
|
|
|
2020-12-08 14:39:28 +00:00
|
|
|
// ListAllBucketsCursor defines cursor for ListAllBuckets listing.
|
|
|
|
type ListAllBucketsCursor struct {
|
|
|
|
ProjectID uuid.UUID
|
|
|
|
BucketName []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListAllBucketsOptions defines ListAllBuckets listing options.
|
|
|
|
type ListAllBucketsOptions struct {
|
|
|
|
Cursor ListAllBucketsCursor
|
|
|
|
Limit int
|
|
|
|
}
|
|
|
|
|
2020-12-05 16:01:42 +00:00
|
|
|
// BucketsDB is the interface for the database to interact with buckets.
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Database
|
2019-07-08 23:32:18 +01:00
|
|
|
type BucketsDB interface {
|
|
|
|
// Create creates a new bucket
|
|
|
|
CreateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error)
|
|
|
|
// Get returns an existing bucket
|
|
|
|
GetBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket storj.Bucket, err error)
|
2020-06-25 15:47:44 +01:00
|
|
|
// GetBucketID returns an existing bucket id.
|
2020-07-24 18:13:15 +01:00
|
|
|
GetBucketID(ctx context.Context, bucket metabase.BucketLocation) (id uuid.UUID, err error)
|
2019-07-19 16:17:34 +01:00
|
|
|
// UpdateBucket updates an existing bucket
|
|
|
|
UpdateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error)
|
2019-07-08 23:32:18 +01:00
|
|
|
// Delete deletes a bucket
|
|
|
|
DeleteBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (err error)
|
|
|
|
// List returns all buckets for a project
|
2019-07-12 13:57:02 +01:00
|
|
|
ListBuckets(ctx context.Context, projectID uuid.UUID, listOpts storj.BucketListOptions, allowedBuckets macaroon.AllowedBuckets) (bucketList storj.BucketList, err error)
|
2020-12-08 14:39:28 +00:00
|
|
|
// ListAllBuckets returns a list of all buckets.
|
|
|
|
ListAllBuckets(ctx context.Context, listOpts ListAllBucketsOptions) (bucketList storj.BucketList, err error)
|
2020-06-30 22:49:29 +01:00
|
|
|
// CountBuckets returns the number of buckets a project currently has
|
|
|
|
CountBuckets(ctx context.Context, projectID uuid.UUID) (int, error)
|
2019-07-08 23:32:18 +01:00
|
|
|
}
|