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