github.com/cloudwan/edgelq-sdk@v1.15.4/logging/resources/v1/bucket/bucket.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: Bucket 3 // DO NOT EDIT!!! 4 5 package bucket 6 7 import ( 8 "context" 9 10 "google.golang.org/grpc/codes" 11 "google.golang.org/grpc/status" 12 13 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 14 gotenresource "github.com/cloudwan/goten-sdk/runtime/resource" 15 "github.com/cloudwan/goten-sdk/types/watch_type" 16 ) 17 18 // proto imports 19 import ( 20 iam_organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization" 21 iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 22 log_descriptor "github.com/cloudwan/edgelq-sdk/logging/resources/v1/log_descriptor" 23 meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service" 24 meta "github.com/cloudwan/goten-sdk/types/meta" 25 ) 26 27 // ensure the imports are used 28 var ( 29 _ = new(context.Context) 30 31 _ = codes.Internal 32 _ = status.Status{} 33 34 _ = watch_type.WatchType_STATEFUL 35 _ = new(gotenobject.FieldPath) 36 _ = new(gotenresource.ListQuery) 37 ) 38 39 // make sure we're using proto imports 40 var ( 41 _ = &iam_organization.Organization{} 42 _ = &iam_project.Project{} 43 _ = &log_descriptor.LogDescriptor{} 44 _ = &meta_service.Service{} 45 _ = &meta.Meta{} 46 ) 47 48 type BucketAccess interface { 49 GetBucket(context.Context, *GetQuery, ...gotenresource.GetOption) (*Bucket, error) 50 BatchGetBuckets(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 51 QueryBuckets(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 52 WatchBucket(context.Context, *GetQuery, func(*BucketChange) error) error 53 WatchBuckets(context.Context, *WatchQuery, func(*QueryResultChange) error) error 54 SaveBucket(context.Context, *Bucket, ...gotenresource.SaveOption) error 55 DeleteBucket(context.Context, *Reference, ...gotenresource.DeleteOption) error 56 } 57 58 type anyCastAccess struct { 59 BucketAccess 60 } 61 62 func AsAnyCastAccess(access BucketAccess) gotenresource.Access { 63 return &anyCastAccess{BucketAccess: access} 64 } 65 66 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 67 if asBucketQuery, ok := q.(*GetQuery); ok { 68 return a.GetBucket(ctx, asBucketQuery, opts...) 69 } 70 return nil, status.Errorf(codes.Internal, 71 "Unrecognized descriptor, expected Bucket, got: %s", 72 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 73 } 74 75 func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 76 if asBucketQuery, ok := q.(*ListQuery); ok { 77 return a.QueryBuckets(ctx, asBucketQuery, opts...) 78 } 79 return nil, status.Errorf(codes.Internal, 80 "Unrecognized descriptor, expected Bucket, got: %s", 81 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 82 } 83 84 func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 85 return nil, status.Errorf(codes.Internal, "Search is not available for Bucket") 86 } 87 88 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 89 if asBucketQuery, ok := q.(*GetQuery); ok { 90 return a.WatchBucket(ctx, asBucketQuery, func(change *BucketChange) error { 91 return cb(change) 92 }) 93 } 94 return status.Errorf(codes.Internal, 95 "Unrecognized descriptor, expected Bucket, got: %s", 96 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 97 } 98 99 func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error { 100 if asBucketQuery, ok := q.(*WatchQuery); ok { 101 return a.WatchBuckets(ctx, asBucketQuery, func(change *QueryResultChange) error { 102 return cb(change) 103 }) 104 } 105 return status.Errorf(codes.Internal, 106 "Unrecognized descriptor, expected Bucket, got: %s", 107 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 108 } 109 110 func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error { 111 if asBucketRes, ok := res.(*Bucket); ok { 112 return a.SaveBucket(ctx, asBucketRes, opts...) 113 } 114 return status.Errorf(codes.Internal, 115 "Unrecognized descriptor, expected Bucket, got: %s", 116 res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 117 } 118 119 func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error { 120 if asBucketRef, ok := ref.(*Reference); ok { 121 return a.DeleteBucket(ctx, asBucketRef, opts...) 122 } 123 return status.Errorf(codes.Internal, 124 "Unrecognized descriptor, expected Bucket, got: %s", 125 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 126 } 127 128 func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error { 129 bucketRefs := make([]*Reference, 0, len(toGet)) 130 for _, ref := range toGet { 131 if asBucketRef, ok := ref.(*Reference); !ok { 132 return status.Errorf(codes.Internal, 133 "Unrecognized descriptor, expected Bucket, got: %s", 134 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 135 } else { 136 bucketRefs = append(bucketRefs, asBucketRef) 137 } 138 } 139 return a.BatchGetBuckets(ctx, bucketRefs, opts...) 140 } 141 142 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 143 return []gotenresource.Descriptor{ 144 GetDescriptor(), 145 } 146 }