forked from journeymidnight/yig
/
object-interface.go
executable file
·96 lines (89 loc) · 5.32 KB
/
object-interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
*
* 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.
*/
package api
import (
"github.com/journeymidnight/yig/api/datatype"
"github.com/journeymidnight/yig/api/datatype/policy"
"github.com/journeymidnight/yig/iam/common"
meta "github.com/journeymidnight/yig/meta/types"
"io"
)
// ObjectLayer implements primitives for object API layer.
type ObjectLayer interface {
// Bucket operations.
MakeBucket(bucket string, acl datatype.Acl, credential common.Credential) error
SetBucketLc(bucket string, config datatype.Lc,
credential common.Credential) error
GetBucketLc(bucket string, credential common.Credential) (datatype.Lc, error)
DelBucketLc(bucket string, credential common.Credential) error
SetBucketAcl(bucket string, policy datatype.AccessControlPolicy, acl datatype.Acl,
credential common.Credential) error
GetBucketAcl(bucket string, credential common.Credential) (datatype.AccessControlPolicyResponse, error)
SetBucketCors(bucket string, cors datatype.Cors, credential common.Credential) error
SetBucketVersioning(bucket string, versioning datatype.Versioning, credential common.Credential) error
DeleteBucketCors(bucket string, credential common.Credential) error
GetBucketVersioning(bucket string, credential common.Credential) (datatype.Versioning, error)
GetBucketCors(bucket string, credential common.Credential) (datatype.Cors, error)
GetBucket(bucketName string) (bucket meta.Bucket, err error) // For INTERNAL USE ONLY
GetBucketInfo(bucket string, credential common.Credential) (bucketInfo meta.Bucket, err error)
ListBuckets(credential common.Credential) (buckets []meta.Bucket, err error)
DeleteBucket(bucket string, credential common.Credential) error
ListObjects(credential common.Credential, bucket string,
request datatype.ListObjectsRequest) (result meta.ListObjectsInfo, err error)
ListVersionedObjects(credential common.Credential, bucket string,
request datatype.ListObjectsRequest) (result meta.VersionedListObjectsInfo, err error)
SetBucketPolicy(credential common.Credential, bucket string, policy policy.Policy) error
// Policy operations
GetBucketPolicy(credential common.Credential, bucket string) (policy.Policy, error)
DeleteBucketPolicy(credential common.Credential, bucket string) error
// Object operations.
GetObject(object *meta.Object, startOffset int64, length int64, writer io.Writer,
sse datatype.SseRequest) (err error)
GetObjectInfo(bucket, object, version string, credential common.Credential) (objInfo *meta.Object,
err error)
PutObject(bucket, object string, credential common.Credential, size int64, data io.Reader,
metadata map[string]string, acl datatype.Acl,
sse datatype.SseRequest) (result datatype.PutObjectResult, err error)
AppendObject(bucket, object string, credential common.Credential, offset uint64, size int64, data io.Reader,
metadata map[string]string, acl datatype.Acl,
sse datatype.SseRequest, objInfo *meta.Object) (result datatype.AppendObjectResult, err error)
CopyObject(targetObject *meta.Object, source io.Reader, credential common.Credential,
sse datatype.SseRequest) (result datatype.PutObjectResult, err error)
UpdateObjectAttrs(targetObject *meta.Object, credential common.Credential) (result datatype.PutObjectResult, err error)
SetObjectAcl(bucket string, object string, version string, policy datatype.AccessControlPolicy,
acl datatype.Acl, credential common.Credential) error
GetObjectAcl(bucket string, object string, version string, credential common.Credential) (
policy datatype.AccessControlPolicyResponse, err error)
DeleteObject(bucket, object, version string, credential common.Credential) (datatype.DeleteObjectResult,
error)
// Multipart operations.
ListMultipartUploads(credential common.Credential, bucket string,
request datatype.ListUploadsRequest) (result datatype.ListMultipartUploadsResponse, err error)
NewMultipartUpload(credential common.Credential, bucket, object string,
metadata map[string]string, acl datatype.Acl,
sse datatype.SseRequest) (uploadID string, err error)
PutObjectPart(bucket, object string, credential common.Credential, uploadID string, partID int,
size int64, data io.Reader, md5Hex string,
sse datatype.SseRequest) (result datatype.PutObjectPartResult, err error)
CopyObjectPart(bucketName, objectName, uploadId string, partId int, size int64, data io.Reader,
credential common.Credential, sse datatype.SseRequest) (result datatype.PutObjectResult,
err error)
ListObjectParts(credential common.Credential, bucket, object string,
request datatype.ListPartsRequest) (result datatype.ListPartsResponse, err error)
AbortMultipartUpload(credential common.Credential, bucket, object, uploadID string) error
CompleteMultipartUpload(credential common.Credential, bucket, object, uploadID string,
uploadedParts []meta.CompletePart) (result datatype.CompleteMultipartResult, err error)
}