2016-04-29 23:24:10 +02:00
|
|
|
/*
|
2019-04-09 20:39:42 +02:00
|
|
|
* MinIO Cloud Storage, (C) 2016 MinIO, Inc.
|
2016-04-29 23:24:10 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-08-19 01:23:42 +02:00
|
|
|
package cmd
|
2016-04-29 23:24:10 +02:00
|
|
|
|
2017-09-19 21:40:27 +02:00
|
|
|
import (
|
2018-03-14 20:01:47 +01:00
|
|
|
"context"
|
2017-09-19 21:40:27 +02:00
|
|
|
"io"
|
2018-09-21 04:22:09 +02:00
|
|
|
"net/http"
|
2017-09-19 21:40:27 +02:00
|
|
|
|
2019-05-30 01:35:12 +02:00
|
|
|
"github.com/minio/minio-go/v6/pkg/encrypt"
|
2020-02-05 10:42:34 +01:00
|
|
|
bucketsse "github.com/minio/minio/pkg/bucket/encryption"
|
2020-01-27 23:12:34 +01:00
|
|
|
"github.com/minio/minio/pkg/bucket/lifecycle"
|
|
|
|
"github.com/minio/minio/pkg/bucket/object/tagging"
|
|
|
|
"github.com/minio/minio/pkg/bucket/policy"
|
2020-02-05 10:42:34 +01:00
|
|
|
|
2018-01-22 23:54:55 +01:00
|
|
|
"github.com/minio/minio/pkg/madmin"
|
2017-09-19 21:40:27 +02:00
|
|
|
)
|
2016-04-29 23:24:10 +02:00
|
|
|
|
2019-03-06 21:38:41 +01:00
|
|
|
// CheckCopyPreconditionFn returns true if copy precondition check failed.
|
|
|
|
type CheckCopyPreconditionFn func(o ObjectInfo, encETag string) bool
|
|
|
|
|
2019-11-20 22:18:09 +01:00
|
|
|
// GetObjectInfoFn is the signature of GetObjectInfo function.
|
|
|
|
type GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
|
|
|
|
2018-09-10 18:42:43 +02:00
|
|
|
// ObjectOptions represents object options for ObjectLayer operations
|
|
|
|
type ObjectOptions struct {
|
|
|
|
ServerSideEncryption encrypt.ServerSide
|
2019-02-09 06:31:06 +01:00
|
|
|
UserDefined map[string]string
|
2020-04-21 07:01:59 +02:00
|
|
|
PartNumber int
|
2019-03-06 21:38:41 +01:00
|
|
|
CheckCopyPrecondFn CheckCopyPreconditionFn
|
2018-09-10 18:42:43 +02:00
|
|
|
}
|
|
|
|
|
2018-09-25 21:39:46 +02:00
|
|
|
// LockType represents required locking for ObjectLayer operations
|
|
|
|
type LockType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
noLock LockType = iota
|
|
|
|
readLock
|
|
|
|
writeLock
|
|
|
|
)
|
|
|
|
|
2016-04-29 23:24:10 +02:00
|
|
|
// ObjectLayer implements primitives for object API layer.
|
|
|
|
type ObjectLayer interface {
|
2019-11-13 21:17:45 +01:00
|
|
|
// Locking operations on object.
|
2020-02-21 06:59:57 +01:00
|
|
|
NewNSLock(ctx context.Context, bucket string, objects ...string) RWLocker
|
2019-11-13 21:17:45 +01:00
|
|
|
|
2016-05-26 23:13:10 +02:00
|
|
|
// Storage operations.
|
2018-03-14 20:01:47 +01:00
|
|
|
Shutdown(context.Context) error
|
2020-04-27 19:06:21 +02:00
|
|
|
CrawlAndGetDataUsage(ctx context.Context, bf *bloomFilter, updates chan<- DataUsageInfo) error
|
2020-02-20 04:51:33 +01:00
|
|
|
StorageInfo(ctx context.Context, local bool) StorageInfo // local queries only local disks
|
2016-05-26 23:13:10 +02:00
|
|
|
|
2016-04-29 23:24:10 +02:00
|
|
|
// Bucket operations.
|
2018-03-14 20:01:47 +01:00
|
|
|
MakeBucketWithLocation(ctx context.Context, bucket string, location string) error
|
|
|
|
GetBucketInfo(ctx context.Context, bucket string) (bucketInfo BucketInfo, err error)
|
|
|
|
ListBuckets(ctx context.Context) (buckets []BucketInfo, err error)
|
2020-03-28 05:52:59 +01:00
|
|
|
DeleteBucket(ctx context.Context, bucket string, forceDelete bool) error
|
2018-03-14 20:01:47 +01:00
|
|
|
ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (result ListObjectsInfo, err error)
|
|
|
|
ListObjectsV2(ctx context.Context, bucket, prefix, continuationToken, delimiter string, maxKeys int, fetchOwner bool, startAfter string) (result ListObjectsV2Info, err error)
|
2020-02-25 16:52:28 +01:00
|
|
|
Walk(ctx context.Context, bucket, prefix string, results chan<- ObjectInfo) error
|
2016-04-29 23:24:10 +02:00
|
|
|
|
|
|
|
// Object operations.
|
2018-09-10 18:42:43 +02:00
|
|
|
|
2018-09-21 04:22:09 +02:00
|
|
|
// GetObjectNInfo returns a GetObjectReader that satisfies the
|
|
|
|
// ReadCloser interface. The Close method unlocks the object
|
|
|
|
// after reading, so it must always be called after usage.
|
|
|
|
//
|
|
|
|
// IMPORTANTLY, when implementations return err != nil, this
|
|
|
|
// function MUST NOT return a non-nil ReadCloser.
|
2018-09-27 12:06:45 +02:00
|
|
|
GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (reader *GetObjectReader, err error)
|
2018-09-10 18:42:43 +02:00
|
|
|
GetObject(ctx context.Context, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts ObjectOptions) (err error)
|
|
|
|
GetObjectInfo(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
2019-02-09 06:31:06 +01:00
|
|
|
PutObject(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
2018-09-10 18:42:43 +02:00
|
|
|
CopyObject(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error)
|
2018-03-14 20:01:47 +01:00
|
|
|
DeleteObject(ctx context.Context, bucket, object string) error
|
2019-05-13 21:25:49 +02:00
|
|
|
DeleteObjects(ctx context.Context, bucket string, objects []string) ([]error, error)
|
2016-04-29 23:24:10 +02:00
|
|
|
|
|
|
|
// Multipart operations.
|
2018-03-14 20:01:47 +01:00
|
|
|
ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartsInfo, err error)
|
2019-02-09 06:31:06 +01:00
|
|
|
NewMultipartUpload(ctx context.Context, bucket, object string, opts ObjectOptions) (uploadID string, err error)
|
2018-03-14 20:01:47 +01:00
|
|
|
CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string, partID int,
|
2018-09-10 18:42:43 +02:00
|
|
|
startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (info PartInfo, err error)
|
2018-11-15 02:36:41 +01:00
|
|
|
PutObjectPart(ctx context.Context, bucket, object, uploadID string, partID int, data *PutObjReader, opts ObjectOptions) (info PartInfo, err error)
|
2019-01-05 23:16:43 +01:00
|
|
|
ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker int, maxParts int, opts ObjectOptions) (result ListPartsInfo, err error)
|
2018-03-14 20:01:47 +01:00
|
|
|
AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string) error
|
2018-11-15 02:36:41 +01:00
|
|
|
CompleteMultipartUpload(ctx context.Context, bucket, object, uploadID string, uploadedParts []CompletePart, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
2016-10-15 04:57:40 +02:00
|
|
|
|
|
|
|
// Healing operations.
|
2018-04-09 19:25:41 +02:00
|
|
|
ReloadFormat(ctx context.Context, dryRun bool) error
|
2018-03-14 20:01:47 +01:00
|
|
|
HealFormat(ctx context.Context, dryRun bool) (madmin.HealResultItem, error)
|
2019-02-11 04:53:13 +01:00
|
|
|
HealBucket(ctx context.Context, bucket string, dryRun, remove bool) (madmin.HealResultItem, error)
|
2020-03-19 01:50:00 +01:00
|
|
|
HealObject(ctx context.Context, bucket, object string, opts madmin.HealOpts) (madmin.HealResultItem, error)
|
|
|
|
HealObjects(ctx context.Context, bucket, prefix string, opts madmin.HealOpts, fn healObjectFn) error
|
2018-01-13 05:34:52 +01:00
|
|
|
|
2019-06-09 07:14:07 +02:00
|
|
|
ListBucketsHeal(ctx context.Context) (buckets []BucketInfo, err error)
|
|
|
|
|
2018-02-10 00:19:30 +01:00
|
|
|
// Policy operations
|
2018-04-25 00:53:30 +02:00
|
|
|
SetBucketPolicy(context.Context, string, *policy.Policy) error
|
|
|
|
GetBucketPolicy(context.Context, string) (*policy.Policy, error)
|
2018-03-14 20:01:47 +01:00
|
|
|
DeleteBucketPolicy(context.Context, string) error
|
2018-02-10 00:19:30 +01:00
|
|
|
|
|
|
|
// Supported operations check
|
|
|
|
IsNotificationSupported() bool
|
2018-12-05 23:03:42 +01:00
|
|
|
IsListenBucketSupported() bool
|
2018-02-10 00:19:30 +01:00
|
|
|
IsEncryptionSupported() bool
|
2018-09-28 05:36:17 +02:00
|
|
|
|
|
|
|
// Compression support check.
|
|
|
|
IsCompressionSupported() bool
|
2019-07-19 22:20:33 +02:00
|
|
|
|
|
|
|
// Lifecycle operations
|
|
|
|
SetBucketLifecycle(context.Context, string, *lifecycle.Lifecycle) error
|
|
|
|
GetBucketLifecycle(context.Context, string) (*lifecycle.Lifecycle, error)
|
|
|
|
DeleteBucketLifecycle(context.Context, string) error
|
2019-12-06 08:16:06 +01:00
|
|
|
|
2020-02-05 10:42:34 +01:00
|
|
|
// Bucket Encryption operations
|
|
|
|
SetBucketSSEConfig(context.Context, string, *bucketsse.BucketSSEConfig) error
|
|
|
|
GetBucketSSEConfig(context.Context, string) (*bucketsse.BucketSSEConfig, error)
|
|
|
|
DeleteBucketSSEConfig(context.Context, string) error
|
|
|
|
|
2019-12-06 08:16:06 +01:00
|
|
|
// Backend related metrics
|
|
|
|
GetMetrics(ctx context.Context) (*Metrics, error)
|
2019-12-28 17:54:43 +01:00
|
|
|
|
|
|
|
// Check Readiness
|
|
|
|
IsReady(ctx context.Context) bool
|
2020-01-20 17:45:59 +01:00
|
|
|
|
|
|
|
// ObjectTagging operations
|
|
|
|
PutObjectTag(context.Context, string, string, string) error
|
|
|
|
GetObjectTag(context.Context, string, string) (tagging.Tagging, error)
|
|
|
|
DeleteObjectTag(context.Context, string, string) error
|
2016-04-29 23:24:10 +02:00
|
|
|
}
|