Debian Codegraph @

gcsfs/internal/stiface/interfaces.go

raw
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package stiface
16
17 import (
18 "context"
19 "io"
20
21 "cloud.google.com/go/storage"
22 "google.golang.org/api/iterator"
23 )
24
25 type Client interface {
26 Bucket(name string) BucketHandle
27 Buckets(ctx context.Context, projectID string) BucketIterator
28 Close() error
29
30 embedToIncludeNewMethods()
31 }
32
33 type ObjectHandle interface {
34 ACL() ACLHandle
35 Generation(int64) ObjectHandle
36 If(storage.Conditions) ObjectHandle
37 Key([]byte) ObjectHandle
38 ReadCompressed(bool) ObjectHandle
39 Attrs(context.Context) (*storage.ObjectAttrs, error)
40 Update(context.Context, storage.ObjectAttrsToUpdate) (*storage.ObjectAttrs, error)
41 NewReader(context.Context) (Reader, error)
42 NewRangeReader(context.Context, int64, int64) (Reader, error)
43 NewWriter(context.Context) Writer
44 Delete(context.Context) error
45 CopierFrom(ObjectHandle) Copier
46 ComposerFrom(...ObjectHandle) Composer
47
48 embedToIncludeNewMethods()
49 }
50
51 type BucketHandle interface {
52 Create(context.Context, string, *storage.BucketAttrs) error
53 Delete(context.Context) error
54 DefaultObjectACL() ACLHandle
55 Object(string) ObjectHandle
56 Attrs(context.Context) (*storage.BucketAttrs, error)
57 Update(context.Context, storage.BucketAttrsToUpdate) (*storage.BucketAttrs, error)
58 If(storage.BucketConditions) BucketHandle
59 Objects(context.Context, *storage.Query) ObjectIterator
60 ACL() ACLHandle
61 // IAM() *iam.Handle
62 UserProject(projectID string) BucketHandle
63 Notifications(context.Context) (map[string]*storage.Notification, error)
64 AddNotification(context.Context, *storage.Notification) (*storage.Notification, error)
65 DeleteNotification(context.Context, string) error
66 LockRetentionPolicy(context.Context) error
67
68 embedToIncludeNewMethods()
69 }
70
71 type ObjectIterator interface {
72 Next() (*storage.ObjectAttrs, error)
73 PageInfo() *iterator.PageInfo
74
75 embedToIncludeNewMethods()
76 }
77
78 type BucketIterator interface {
79 SetPrefix(string)
80 Next() (*storage.BucketAttrs, error)
81 PageInfo() *iterator.PageInfo
82
83 embedToIncludeNewMethods()
84 }
85
86 type ACLHandle interface {
87 Delete(context.Context, storage.ACLEntity) error
88 Set(context.Context, storage.ACLEntity, storage.ACLRole) error
89 List(context.Context) ([]storage.ACLRule, error)
90
91 embedToIncludeNewMethods()
92 }
93
94 type Reader interface {
95 io.ReadCloser
96 Size() int64
97 Remain() int64
98 ContentType() string
99 ContentEncoding() string
100 CacheControl() string
101
102 embedToIncludeNewMethods()
103 }
104
105 type Writer interface {
106 io.WriteCloser
107 ObjectAttrs() *storage.ObjectAttrs
108 SetChunkSize(int)
109 SetProgressFunc(func(int64))
110 SetCRC32C(uint32) // Sets both CRC32C and SendCRC32C.
111 CloseWithError(err error) error
112 Attrs() *storage.ObjectAttrs
113
114 embedToIncludeNewMethods()
115 }
116
117 type Copier interface {
118 ObjectAttrs() *storage.ObjectAttrs
119 SetRewriteToken(string)
120 SetProgressFunc(func(uint64, uint64))
121 SetDestinationKMSKeyName(string)
122 Run(context.Context) (*storage.ObjectAttrs, error)
123
124 embedToIncludeNewMethods()
125 }
126
127 type Composer interface {
128 ObjectAttrs() *storage.ObjectAttrs
129 Run(context.Context) (*storage.ObjectAttrs, error)
130
131 embedToIncludeNewMethods()
132 }