github.com/cloudwan/edgelq-sdk@v1.15.4/limits/resources/v1/limit_pool/limit_pool.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: LimitPool 3 // DO NOT EDIT!!! 4 5 package limit_pool 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 meta_resource "github.com/cloudwan/goten-sdk/meta-service/resources/v1/resource" 22 meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service" 23 meta "github.com/cloudwan/goten-sdk/types/meta" 24 ) 25 26 // ensure the imports are used 27 var ( 28 _ = new(context.Context) 29 30 _ = codes.Internal 31 _ = status.Status{} 32 33 _ = watch_type.WatchType_STATEFUL 34 _ = new(gotenobject.FieldPath) 35 _ = new(gotenresource.ListQuery) 36 ) 37 38 // make sure we're using proto imports 39 var ( 40 _ = &iam_organization.Organization{} 41 _ = &meta_resource.Resource{} 42 _ = &meta_service.Service{} 43 _ = &meta.Meta{} 44 ) 45 46 type LimitPoolAccess interface { 47 GetLimitPool(context.Context, *GetQuery, ...gotenresource.GetOption) (*LimitPool, error) 48 BatchGetLimitPools(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 49 QueryLimitPools(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 50 WatchLimitPool(context.Context, *GetQuery, func(*LimitPoolChange) error) error 51 WatchLimitPools(context.Context, *WatchQuery, func(*QueryResultChange) error) error 52 SaveLimitPool(context.Context, *LimitPool, ...gotenresource.SaveOption) error 53 DeleteLimitPool(context.Context, *Reference, ...gotenresource.DeleteOption) error 54 } 55 56 type anyCastAccess struct { 57 LimitPoolAccess 58 } 59 60 func AsAnyCastAccess(access LimitPoolAccess) gotenresource.Access { 61 return &anyCastAccess{LimitPoolAccess: access} 62 } 63 64 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 65 if asLimitPoolQuery, ok := q.(*GetQuery); ok { 66 return a.GetLimitPool(ctx, asLimitPoolQuery, opts...) 67 } 68 return nil, status.Errorf(codes.Internal, 69 "Unrecognized descriptor, expected LimitPool, got: %s", 70 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 71 } 72 73 func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 74 if asLimitPoolQuery, ok := q.(*ListQuery); ok { 75 return a.QueryLimitPools(ctx, asLimitPoolQuery, opts...) 76 } 77 return nil, status.Errorf(codes.Internal, 78 "Unrecognized descriptor, expected LimitPool, got: %s", 79 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 80 } 81 82 func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 83 return nil, status.Errorf(codes.Internal, "Search is not available for LimitPool") 84 } 85 86 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 87 if asLimitPoolQuery, ok := q.(*GetQuery); ok { 88 return a.WatchLimitPool(ctx, asLimitPoolQuery, func(change *LimitPoolChange) error { 89 return cb(change) 90 }) 91 } 92 return status.Errorf(codes.Internal, 93 "Unrecognized descriptor, expected LimitPool, got: %s", 94 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 95 } 96 97 func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error { 98 if asLimitPoolQuery, ok := q.(*WatchQuery); ok { 99 return a.WatchLimitPools(ctx, asLimitPoolQuery, func(change *QueryResultChange) error { 100 return cb(change) 101 }) 102 } 103 return status.Errorf(codes.Internal, 104 "Unrecognized descriptor, expected LimitPool, got: %s", 105 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 106 } 107 108 func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error { 109 if asLimitPoolRes, ok := res.(*LimitPool); ok { 110 return a.SaveLimitPool(ctx, asLimitPoolRes, opts...) 111 } 112 return status.Errorf(codes.Internal, 113 "Unrecognized descriptor, expected LimitPool, got: %s", 114 res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 115 } 116 117 func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error { 118 if asLimitPoolRef, ok := ref.(*Reference); ok { 119 return a.DeleteLimitPool(ctx, asLimitPoolRef, opts...) 120 } 121 return status.Errorf(codes.Internal, 122 "Unrecognized descriptor, expected LimitPool, got: %s", 123 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 124 } 125 126 func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error { 127 limitPoolRefs := make([]*Reference, 0, len(toGet)) 128 for _, ref := range toGet { 129 if asLimitPoolRef, ok := ref.(*Reference); !ok { 130 return status.Errorf(codes.Internal, 131 "Unrecognized descriptor, expected LimitPool, got: %s", 132 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 133 } else { 134 limitPoolRefs = append(limitPoolRefs, asLimitPoolRef) 135 } 136 } 137 return a.BatchGetLimitPools(ctx, limitPoolRefs, opts...) 138 } 139 140 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 141 return []gotenresource.Descriptor{ 142 GetDescriptor(), 143 } 144 }