github.com/cloudwan/edgelq-sdk@v1.15.4/applications/resources/v1alpha2/pod/pod.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: Pod 3 // DO NOT EDIT!!! 4 5 package pod 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 common "github.com/cloudwan/edgelq-sdk/applications/resources/v1alpha2/common" 21 distribution "github.com/cloudwan/edgelq-sdk/applications/resources/v1alpha2/distribution" 22 project "github.com/cloudwan/edgelq-sdk/applications/resources/v1alpha2/project" 23 meta "github.com/cloudwan/goten-sdk/types/meta" 24 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 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 _ = &common.PodSpec{} 42 _ = &distribution.Distribution{} 43 _ = &project.Project{} 44 _ = ×tamppb.Timestamp{} 45 _ = &meta.Meta{} 46 ) 47 48 type PodAccess interface { 49 GetPod(context.Context, *GetQuery, ...gotenresource.GetOption) (*Pod, error) 50 BatchGetPods(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 51 QueryPods(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 52 WatchPod(context.Context, *GetQuery, func(*PodChange) error) error 53 WatchPods(context.Context, *WatchQuery, func(*QueryResultChange) error) error 54 SavePod(context.Context, *Pod, ...gotenresource.SaveOption) error 55 DeletePod(context.Context, *Reference, ...gotenresource.DeleteOption) error 56 } 57 58 type anyCastAccess struct { 59 PodAccess 60 } 61 62 func AsAnyCastAccess(access PodAccess) gotenresource.Access { 63 return &anyCastAccess{PodAccess: access} 64 } 65 66 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 67 if asPodQuery, ok := q.(*GetQuery); ok { 68 return a.GetPod(ctx, asPodQuery, opts...) 69 } 70 return nil, status.Errorf(codes.Internal, 71 "Unrecognized descriptor, expected Pod, 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 asPodQuery, ok := q.(*ListQuery); ok { 77 return a.QueryPods(ctx, asPodQuery, opts...) 78 } 79 return nil, status.Errorf(codes.Internal, 80 "Unrecognized descriptor, expected Pod, 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 Pod") 86 } 87 88 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 89 if asPodQuery, ok := q.(*GetQuery); ok { 90 return a.WatchPod(ctx, asPodQuery, func(change *PodChange) error { 91 return cb(change) 92 }) 93 } 94 return status.Errorf(codes.Internal, 95 "Unrecognized descriptor, expected Pod, 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 asPodQuery, ok := q.(*WatchQuery); ok { 101 return a.WatchPods(ctx, asPodQuery, func(change *QueryResultChange) error { 102 return cb(change) 103 }) 104 } 105 return status.Errorf(codes.Internal, 106 "Unrecognized descriptor, expected Pod, 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 asPodRes, ok := res.(*Pod); ok { 112 return a.SavePod(ctx, asPodRes, opts...) 113 } 114 return status.Errorf(codes.Internal, 115 "Unrecognized descriptor, expected Pod, 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 asPodRef, ok := ref.(*Reference); ok { 121 return a.DeletePod(ctx, asPodRef, opts...) 122 } 123 return status.Errorf(codes.Internal, 124 "Unrecognized descriptor, expected Pod, 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 podRefs := make([]*Reference, 0, len(toGet)) 130 for _, ref := range toGet { 131 if asPodRef, ok := ref.(*Reference); !ok { 132 return status.Errorf(codes.Internal, 133 "Unrecognized descriptor, expected Pod, got: %s", 134 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 135 } else { 136 podRefs = append(podRefs, asPodRef) 137 } 138 } 139 return a.BatchGetPods(ctx, podRefs, opts...) 140 } 141 142 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 143 return []gotenresource.Descriptor{ 144 GetDescriptor(), 145 } 146 }