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