github.com/cloudwan/edgelq-sdk@v1.15.4/limits/resources/v1/limit/limit.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: Limit 3 // DO NOT EDIT!!! 4 5 package limit 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_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 21 limit_pool "github.com/cloudwan/edgelq-sdk/limits/resources/v1/limit_pool" 22 meta_resource "github.com/cloudwan/goten-sdk/meta-service/resources/v1/resource" 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_project.Project{} 42 _ = &limit_pool.LimitPool{} 43 _ = &meta_resource.Resource{} 44 _ = &meta_service.Service{} 45 _ = &meta.Meta{} 46 ) 47 48 type LimitAccess interface { 49 GetLimit(context.Context, *GetQuery, ...gotenresource.GetOption) (*Limit, error) 50 BatchGetLimits(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 51 QueryLimits(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 52 WatchLimit(context.Context, *GetQuery, func(*LimitChange) error) error 53 WatchLimits(context.Context, *WatchQuery, func(*QueryResultChange) error) error 54 SaveLimit(context.Context, *Limit, ...gotenresource.SaveOption) error 55 DeleteLimit(context.Context, *Reference, ...gotenresource.DeleteOption) error 56 } 57 58 type anyCastAccess struct { 59 LimitAccess 60 } 61 62 func AsAnyCastAccess(access LimitAccess) gotenresource.Access { 63 return &anyCastAccess{LimitAccess: access} 64 } 65 66 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 67 if asLimitQuery, ok := q.(*GetQuery); ok { 68 return a.GetLimit(ctx, asLimitQuery, opts...) 69 } 70 return nil, status.Errorf(codes.Internal, 71 "Unrecognized descriptor, expected Limit, 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 asLimitQuery, ok := q.(*ListQuery); ok { 77 return a.QueryLimits(ctx, asLimitQuery, opts...) 78 } 79 return nil, status.Errorf(codes.Internal, 80 "Unrecognized descriptor, expected Limit, 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 Limit") 86 } 87 88 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 89 if asLimitQuery, ok := q.(*GetQuery); ok { 90 return a.WatchLimit(ctx, asLimitQuery, func(change *LimitChange) error { 91 return cb(change) 92 }) 93 } 94 return status.Errorf(codes.Internal, 95 "Unrecognized descriptor, expected Limit, 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 asLimitQuery, ok := q.(*WatchQuery); ok { 101 return a.WatchLimits(ctx, asLimitQuery, func(change *QueryResultChange) error { 102 return cb(change) 103 }) 104 } 105 return status.Errorf(codes.Internal, 106 "Unrecognized descriptor, expected Limit, 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 asLimitRes, ok := res.(*Limit); ok { 112 return a.SaveLimit(ctx, asLimitRes, opts...) 113 } 114 return status.Errorf(codes.Internal, 115 "Unrecognized descriptor, expected Limit, 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 asLimitRef, ok := ref.(*Reference); ok { 121 return a.DeleteLimit(ctx, asLimitRef, opts...) 122 } 123 return status.Errorf(codes.Internal, 124 "Unrecognized descriptor, expected Limit, 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 limitRefs := make([]*Reference, 0, len(toGet)) 130 for _, ref := range toGet { 131 if asLimitRef, ok := ref.(*Reference); !ok { 132 return status.Errorf(codes.Internal, 133 "Unrecognized descriptor, expected Limit, got: %s", 134 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 135 } else { 136 limitRefs = append(limitRefs, asLimitRef) 137 } 138 } 139 return a.BatchGetLimits(ctx, limitRefs, opts...) 140 } 141 142 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 143 return []gotenresource.Descriptor{ 144 GetDescriptor(), 145 } 146 }