2016-04-29 17:24:10 -04:00
|
|
|
/*
|
2019-04-09 14:39:42 -04:00
|
|
|
* MinIO Cloud Storage, (C) 2016 MinIO, Inc.
|
2016-04-29 17:24:10 -04: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-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-04-29 17:24:10 -04:00
|
|
|
|
2017-09-19 15:40:27 -04:00
|
|
|
import (
|
2018-03-14 15:01:47 -04:00
|
|
|
"context"
|
2017-09-19 15:40:27 -04:00
|
|
|
"io"
|
2018-09-20 22:22:09 -04:00
|
|
|
"net/http"
|
2017-09-19 15:40:27 -04:00
|
|
|
|
2019-05-29 19:35:12 -04:00
|
|
|
"github.com/minio/minio-go/v6/pkg/encrypt"
|
2020-02-05 04:42:34 -05:00
|
|
|
bucketsse "github.com/minio/minio/pkg/bucket/encryption"
|
2020-01-27 17:12:34 -05: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 04:42:34 -05:00
|
|
|
|
2018-01-22 17:54:55 -05:00
|
|
|
"github.com/minio/minio/pkg/madmin"
|
2017-09-19 15:40:27 -04:00
|
|
|
)
|
2016-04-29 17:24:10 -04:00
|
|
|
|
2019-03-06 15:38:41 -05:00
|
|
|
// CheckCopyPreconditionFn returns true if copy precondition check failed.
|
|
|
|
type CheckCopyPreconditionFn func(o ObjectInfo, encETag string) bool
|
|
|
|
|
2019-11-20 16:18:09 -05: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 12:42:43 -04:00
|
|
|
// ObjectOptions represents object options for ObjectLayer operations
|
|
|
|
type ObjectOptions struct {
|
|
|
|
ServerSideEncryption encrypt.ServerSide
|
2019-02-09 00:31:06 -05:00
|
|
|
UserDefined map[string]string
|
2019-03-06 15:38:41 -05:00
|
|
|
CheckCopyPrecondFn CheckCopyPreconditionFn
|
2018-09-10 12:42:43 -04:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:39:46 -04:00
|
|
|
// LockType represents required locking for ObjectLayer operations
|
|
|
|
type LockType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
noLock LockType = iota
|
|
|
|
readLock
|
|
|
|
writeLock
|
|
|
|
)
|
|
|
|
|
2016-04-29 17:24:10 -04:00
|
|
|
// ObjectLayer implements primitives for object API layer.
|
|
|
|
type ObjectLayer interface {
|
2019-11-13 15:17:45 -05:00
|
|
|
// Locking operations on object.
|
2020-02-21 00:59:57 -05:00
|
|
|
NewNSLock(ctx context.Context, bucket string, objects ...string) RWLocker
|
2019-11-13 15:17:45 -05:00
|
|
|
|
2016-05-26 17:13:10 -04:00
|
|
|
// Storage operations.
|
2018-03-14 15:01:47 -04:00
|
|
|
Shutdown(context.Context) error
|
2020-01-21 17:07:49 -05:00
|
|
|
CrawlAndGetDataUsage(context.Context, <-chan struct{}) DataUsageInfo
|
2020-02-19 22:51:33 -05:00
|
|
|
StorageInfo(ctx context.Context, local bool) StorageInfo // local queries only local disks
|
2016-05-26 17:13:10 -04:00
|
|
|
|
2016-04-29 17:24:10 -04:00
|
|
|
// Bucket operations.
|
2018-03-14 15:01:47 -04: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)
|
|
|
|
DeleteBucket(ctx context.Context, bucket string) error
|
|
|
|
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 10:52:28 -05:00
|
|
|
Walk(ctx context.Context, bucket, prefix string, results chan<- ObjectInfo) error
|
2016-04-29 17:24:10 -04:00
|
|
|
|
|
|
|
// Object operations.
|
2018-09-10 12:42:43 -04:00
|
|
|
|
2018-09-20 22:22:09 -04: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 06:06:45 -04:00
|
|
|
GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (reader *GetObjectReader, err error)
|
2018-09-10 12:42:43 -04: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 00:31:06 -05:00
|
|
|
PutObject(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
2018-09-10 12:42:43 -04:00
|
|
|
CopyObject(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (objInfo ObjectInfo, err error)
|
2018-03-14 15:01:47 -04:00
|
|
|
DeleteObject(ctx context.Context, bucket, object string) error
|
2019-05-13 15:25:49 -04:00
|
|
|
DeleteObjects(ctx context.Context, bucket string, objects []string) ([]error, error)
|
2016-04-29 17:24:10 -04:00
|
|
|
|
|
|
|
// Multipart operations.
|
2018-03-14 15:01:47 -04:00
|
|
|
ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartsInfo, err error)
|
2019-02-09 00:31:06 -05:00
|
|
|
NewMultipartUpload(ctx context.Context, bucket, object string, opts ObjectOptions) (uploadID string, err error)
|
2018-03-14 15:01:47 -04:00
|
|
|
CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string, partID int,
|
2018-09-10 12:42:43 -04:00
|
|
|
startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (info PartInfo, err error)
|
2018-11-14 20:36:41 -05:00
|
|
|
PutObjectPart(ctx context.Context, bucket, object, uploadID string, partID int, data *PutObjReader, opts ObjectOptions) (info PartInfo, err error)
|
2019-01-05 17:16:43 -05:00
|
|
|
ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker int, maxParts int, opts ObjectOptions) (result ListPartsInfo, err error)
|
2018-03-14 15:01:47 -04:00
|
|
|
AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string) error
|
2018-11-14 20:36:41 -05:00
|
|
|
CompleteMultipartUpload(ctx context.Context, bucket, object, uploadID string, uploadedParts []CompletePart, opts ObjectOptions) (objInfo ObjectInfo, err error)
|
2016-10-14 22:57:40 -04:00
|
|
|
|
|
|
|
// Healing operations.
|
2018-04-09 13:25:41 -04:00
|
|
|
ReloadFormat(ctx context.Context, dryRun bool) error
|
2018-03-14 15:01:47 -04:00
|
|
|
HealFormat(ctx context.Context, dryRun bool) (madmin.HealResultItem, error)
|
2019-02-10 22:53:13 -05:00
|
|
|
HealBucket(ctx context.Context, bucket string, dryRun, remove bool) (madmin.HealResultItem, error)
|
2019-03-14 16:08:51 -04:00
|
|
|
HealObject(ctx context.Context, bucket, object string, dryRun, remove bool, scanMode madmin.HealScanMode) (madmin.HealResultItem, error)
|
2020-02-25 10:52:28 -05:00
|
|
|
|
2020-01-30 06:50:07 -05:00
|
|
|
HealObjects(ctx context.Context, bucket, prefix string, fn healObjectFn) error
|
2018-01-12 23:34:52 -05:00
|
|
|
|
2019-06-09 01:14:07 -04:00
|
|
|
ListBucketsHeal(ctx context.Context) (buckets []BucketInfo, err error)
|
|
|
|
|
2018-02-09 18:19:30 -05:00
|
|
|
// Policy operations
|
2018-04-24 18:53:30 -04:00
|
|
|
SetBucketPolicy(context.Context, string, *policy.Policy) error
|
|
|
|
GetBucketPolicy(context.Context, string) (*policy.Policy, error)
|
2018-03-14 15:01:47 -04:00
|
|
|
DeleteBucketPolicy(context.Context, string) error
|
2018-02-09 18:19:30 -05:00
|
|
|
|
|
|
|
// Supported operations check
|
|
|
|
IsNotificationSupported() bool
|
2018-12-05 17:03:42 -05:00
|
|
|
IsListenBucketSupported() bool
|
2018-02-09 18:19:30 -05:00
|
|
|
IsEncryptionSupported() bool
|
2018-09-27 23:36:17 -04:00
|
|
|
|
|
|
|
// Compression support check.
|
|
|
|
IsCompressionSupported() bool
|
2019-07-19 16:20:33 -04: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 02:16:06 -05:00
|
|
|
|
2020-02-05 04:42:34 -05: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 02:16:06 -05:00
|
|
|
// Backend related metrics
|
|
|
|
GetMetrics(ctx context.Context) (*Metrics, error)
|
2019-12-28 11:54:43 -05:00
|
|
|
|
|
|
|
// Check Readiness
|
|
|
|
IsReady(ctx context.Context) bool
|
2020-01-20 11:45:59 -05: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 17:24:10 -04:00
|
|
|
}
|